<?php

/**
 * Contract form base class.
 *
 * @method Contract getObject() Returns the current form's model object
 *
 * @package    seth
 * @subpackage form
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseContractForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'plant'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => false)),
      'owner'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'add_empty' => false)),
      'type'             => new sfWidgetFormInputText(),
      'start'            => new sfWidgetFormDate(),
      'end'              => new sfWidgetFormDate(),
      'duration'         => new sfWidgetFormInputText(),
      'fee'              => new sfWidgetFormInputText(),
      'istat'            => new sfWidgetFormInputText(),
      'bonus'            => new sfWidgetFormInputText(),
      'penals'           => new sfWidgetFormInputText(),
      're'               => new sfWidgetFormInputText(),
      'an'               => new sfWidgetFormInputText(),
      'pr'               => new sfWidgetFormInputText(),
      'moduleyeardecay'  => new sfWidgetFormInputText(),
      'pr_num'           => new sfWidgetFormInputText(),
      'an_num'           => new sfWidgetFormInputText(),
      'pac'              => new sfWidgetFormDate(),
      'fac'              => new sfWidgetFormDate(),
      'guarprod_kwh'     => new sfWidgetFormInputText(),
      'guargeneral'      => new sfWidgetFormInputText(),
      'guarinv'          => new sfWidgetFormInputText(),
      'guartrasf'        => new sfWidgetFormInputText(),
      'guarmvswitch'     => new sfWidgetFormInputText(),
      'guarpowercenter'  => new sfWidgetFormInputText(),
      'guarcables'       => new sfWidgetFormInputText(),
      'guarstructure'    => new sfWidgetFormInputText(),
      'guaraircond'      => new sfWidgetFormInputText(),
      'guarmodules'      => new sfWidgetFormInputText(),
      'guarsecurity'     => new sfWidgetFormInputText(),
      'costextramaint'   => new sfWidgetFormInputText(),
      'costspareparts'   => new sfWidgetFormInputText(),
      'cleaningsperyear' => new sfWidgetFormInputText(),
      'grasscutyear'     => new sfWidgetFormInputText(),
      'prevmaintyear'    => new sfWidgetFormInputText(),
      'roadmaint'        => new sfWidgetFormInputText(),
      'guardians'        => new sfWidgetFormInputText(),
      'fidejussioni'     => new sfWidgetFormInputText(),
      'credits'          => new sfWidgetFormInputText(),
      'safetydocs'       => new sfWidgetFormInputText(),
      'note1'            => new sfWidgetFormInputText(),
      'note2'            => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'plant'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'))),
      'owner'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Client'))),
      'type'             => new sfValidatorString(array('max_length' => 45)),
      'start'            => new sfValidatorDate(array('required' => false)),
      'end'              => new sfValidatorDate(array('required' => false)),
      'duration'         => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'fee'              => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'istat'            => new sfValidatorInteger(array('required' => false)),
      'bonus'            => new sfValidatorString(array('max_length' => 160, 'required' => false)),
      'penals'           => new sfValidatorString(array('max_length' => 160, 'required' => false)),
      're'               => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'an'               => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pr'               => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'moduleyeardecay'  => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pr_num'           => new sfValidatorNumber(array('required' => false)),
      'an_num'           => new sfValidatorNumber(array('required' => false)),
      'pac'              => new sfValidatorDate(array('required' => false)),
      'fac'              => new sfValidatorDate(array('required' => false)),
      'guarprod_kwh'     => new sfValidatorNumber(array('required' => false)),
      'guargeneral'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarinv'          => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guartrasf'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarmvswitch'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarpowercenter'  => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarcables'       => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarstructure'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guaraircond'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarmodules'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guarsecurity'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'costextramaint'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'costspareparts'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'cleaningsperyear' => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'grasscutyear'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'prevmaintyear'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'roadmaint'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'guardians'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'fidejussioni'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'credits'          => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'safetydocs'       => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'note1'            => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'note2'            => new sfValidatorString(array('max_length' => 45, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('contract[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contract';
  }

}
